from python_baway.common.xcommon import input_value_util_well


class Login:

    def __init__(self, uname, pwd):
        self.uname = uname
        self.pwd = pwd

    def login(self):
        xuname = input_value_util_well(str, 'Please input username: ',
                                       ((lambda x: len(x)), 'Username cannot be empty'))
        xpwd = input_value_util_well(str, 'Please input password: ')
        if xuname == self.uname and xpwd == self.pwd:
            return True
        else:
            return False

    def login_until_well(self):
        while not self.login():
            print('Login failed!')
        else:
            print('Login OK!')


l = Login('user', 'pwd')
l.login_until_well()
